package cn.iocoder.yudao.module.promotion.api.rankinglist;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.promotion.api.rankinglist.dto.RankingListDto;
import cn.iocoder.yudao.module.promotion.dal.dataobject.rankinglist.RankingListDO;
import cn.iocoder.yudao.module.promotion.service.rankinglist.RankingListService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.time.LocalDateTime;

@Service
@Validated
public class RankingListApiImpl implements RankingListApi{

    @Resource
    private RankingListService rankingListService;

    @Override
    public RankingListDto getRankingListNow() {
        LocalDateTime now = LocalDateTime.now();
        RankingListDO rankingListDO = rankingListService.getRankingListNow(now);
        if(null!=rankingListDO){
            return  BeanUtils.toBean(rankingListDO,RankingListDto.class);
        }
        return null;
    }
}
